package edu.vt.ece.rt.quorum.messsages;

import java.io.Serializable;

import org.jgroups.Address;
import org.jgroups.Message;

/*
 * Base Message Type for all messages in QR
 * @author Sudhanshu
 * Should be used to create any new message
 */
public class QMessage implements Serializable{ 
	public static enum MessageType {
		Muter, /* Use to mute a node */
		ReadRequest,/*Use to Request object */
		ReadResponse,/*Use to Provide object */
		CommitRequest,/*Request to commit Object, Request to Register new Object in Quorum*/
		CommitResponse,/*Response if commit Allowed*/
		CommitConfirm, 	 /*Response if Commit done at initiator*/
		JoinCluster,   /* To Request other nodes to join a cluster of given name*/		
		MeasureCost,	 /* To measure communication cost between nodes*/
		PublishObject,	/*Public the new object in System*/
		BenchCompletion, 
		ReadValidate, 
		ReadValidateResponse
	}

	
	MessageType type;

	public QMessage(MessageType t) {
		type = t;
	}
	
	/*
	 * Updated on Receive by message Handler
	 */
	Address src_addr;
	public String messageId;
	
	public void setSrcAddr(Address src){
		src_addr = src;
	}
	
	public Address getSrcAddr(){
		return src_addr;
	}

//	public QMessage(Address dest, MessageType t) {
////		super(dest);
//		type = t;
//	}
//
//	public QMessage(Address dest, Address src, byte[] buf, MessageType t) {
////		super(dest, src, buf);
//		type = t;
//	}
//
//	public QMessage(Address dest, byte[] buf, MessageType t) {
////		super(dest, buf);
//		type = t;
//	}
//
//	public QMessage(Address dest, Address src, byte[] buf, int offset,
//			int length, MessageType t) {
////		super(dest, src, buf, offset, length);
//		type = t;
//	}
//
//	public QMessage(Address dest, byte[] buf, int offset, int length, MessageType t) {
////		super(dest, null, buf, offset, length);
//		type = t;
//	}
//
//	public QMessage(Address dest, Address src, Object obj, MessageType t) {
////		super(dest, src, obj);
//		type = t;
//	}
//
//	public QMessage(Address dest, Object obj, MessageType t) {
////		super(dest, obj);
//		type = t;
//	}
//
//	public QMessage(boolean create_headers, MessageType t) {
////		super(create_headers);
//		type = t;
//	}

	public MessageType getMessageType() {
		return type;
	}

	public void setMessageType(MessageType t) {
		type = t;
	}


}
